#include "Main.h"
#include "gui/MainFrame.h"
#include "gui/wxCamViewWindow.h"
#include "Camera.h" 
#include "CamThread.h"


IMPLEMENT_APP(App)
 
App::App()
{ 
} 

bool App::OnInit()
	{
		wxInitAllImageHandlers() ; 
		MainFrame *frame = new MainFrame(NULL);
		wxCamViewWindow* camView = new wxCamViewWindow(frame,wxPoint(5,15), wxSize(354, 256));
		Camera* camera = new Camera();
		camView->setCam(camera);
		frame->assignCamWindow(camView);
		frame->Show(true);
		
		
		CamThread* camThread= new CamThread(frame);
		// create thread or fail on exit
		if ( camThread->Create() != wxTHREAD_NO_ERROR )
		{
			cout<<"error create!"<<endl;
			wxExit( );
		}
		camThread->camView = camView;
		
		
		if ( camThread->Run() != wxTHREAD_NO_ERROR )
		{
			cout<<"error run!"<<endl;
			wxExit( );
		} 
		
		return true;
	}

